<template>
  <div>
    <router-view v-if="$route.path =='/home/search'"></router-view>
    <div v-else>    
      <van-search v-model="value" @click="$router.push('/home/search')" shape='round' placeholder="请输入搜索关键词" />
      <swipt :banner='bannerArr'/>
      <grid :channelArr='channelArr'/>
      <branding :brandList='brandList'/>
      <newGoodsList :newGoodsList='newGoodsList'/>
      <hotGoodsList :hotGoodsList='hotGoodsList'/>
      <topicList :topicList='topicList'/>
      <categoryList :categoryList='categoryList'/>
    </div>
  </div>
</template>

<script>
// 导入axios请求
import  { getIndexData } from "@/https/http";

// 导入轮播图组件
import  swipt from "@/components/swipt";

// 导入宫格导航栏组件
import grid from "@/components/home/grid";

// 导入品牌供应商组件
import branding from "@/components/home/branding";

// 导入新品首发组件
import newGoodsList from "@/components/home/newGoodsList";

// 导入人气推荐组件
import hotGoodsList from "@/components/home/hotGoodsList";

// 导入专题精选组件
import topicList from "@/components/home/topicList";

// 导入列表组件
import categoryList from "@/components/home/categoryList";

export default {
  data() {
    return {
      value:'',
      bannerArr:[],
      channelArr:[],
      brandList:[],
      newGoodsList:[],
      hotGoodsList:[],
      topicList:[],
      categoryList:[]
    }
  },
  components:{
    swipt,
    grid,
    branding,
    newGoodsList,
    hotGoodsList,
    topicList,
    categoryList
  },
  mounted(){
    console.log(33,this.$route);
    getIndexData().then(res=>{
      console.log(res.data.data);
      let {banner,channel,brandList,newGoodsList,hotGoodsList,topicList,categoryList} = res.data.data
      this.bannerArr = banner
      this.channelArr = channel
      this.brandList = brandList
      this.newGoodsList = newGoodsList
      this.hotGoodsList = hotGoodsList
      this.topicList = topicList
      this.categoryList = categoryList
    })
  }
}
</script>

<style>

</style>